package cn.hdu.liang.holding;

import java.util.LinkedList;

public class Exam15 {

    public static void main(String[] args) {
        LinkedList<Character> stack = new LinkedList<>();
        String s = "+U+n+c---+e+r+t---+a-+i-+n+t+y---+-+r+u--+l+e+s---";
        System.out.println(s);

        for(int i = 0; i < s.length(); i++) {

            switch(s.charAt(i)) {
                case '+':
                    stack.push(s.charAt(i + 1));
                    i++;
                    break;
                case '-':
                    System.out.print(stack.pop() + " ");
                    break;
                default:
                    break;
            }
        }
        System.out.println();
        System.out.println(stack);

    }

}
